const state = {
  items: [
  ],
  isLoadRoutes: false
}

const mutations = {
  [types.EXPAND_MENU] (state, menuItem) {
    if (menuItem.index > -1) {
      if (state.items[menuItem.index] && state.items[menuItem.index].meta) {
        state.items[menuItem.index].meta.expanded = menuItem.expanded
      }
    } else if (menuItem.item && 'expanded' in menuItem.item.meta) {
      menuItem.item.meta.expanded = menuItem.expanded
    }
  },
  [types.ADD_MENU] (state, menuItems) {
    if (menuItems.length === 0) {
      state.items = []
    } else {
      generateMenuItems(state.items, menuItems)
    }
  },
  [types.LOAD_ROUTES] (state) {
    state.isLoadRoutes = !state.isLoadRoutes
  }
}
